//
//  HJBubbleMessageCell.m
//  XWC
//
//  Created by Hello on 2022/10/25.
//

#import "HJChatBubbleMessageCell.h"
#import "HJChatMessageBubbleLayout.h"
#import "HJChatMessageModel.h"

@implementation HJChatBubbleMessageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIImageView *bubbleView = [UIImageView addToView:self.contentView];
        _bubbleView = bubbleView;
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _bubbleView.frame = self.messageLayout.containerViewRect;
}

- (void)setMessageLayout:(HJChatMessageLayout *)messageLayout {
    [super setMessageLayout:messageLayout];
    
    HJChatMessageBubbleLayout *messageCellData = (HJChatMessageBubbleLayout *)messageLayout;
    self.bubbleView.layer.mask = messageCellData.maskLayer;

    if (TJIM_isSelf(messageLayout.messageModel.senderId)) {
        _bubbleView.backgroundColor = UIColorMake(0xEDE6FF);
    } else {
        _bubbleView.backgroundColor = UIColor.whiteColor;
    }
}

@end
